package www.wen.com.common.lib.view

import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.View
import android.widget.RelativeLayout
import androidx.databinding.DataBindingUtil
import www.wen.com.common.R
import www.wen.com.common.databinding.ChannelDetailHeaderBinding

class ChannelDetailHeader @JvmOverloads constructor(
    context: Context, attrs: AttributeSet? = null
) : RelativeLayout(context, attrs) {
    private val binding: ChannelDetailHeaderBinding? = DataBindingUtil.inflate(
        LayoutInflater.from(context),
        R.layout.channel_detail_header,
        this,
        true
    )

    fun setType(type:String){
        when (type) {
            //规则与公告
            "1" -> {
                binding?.apply {
                    llMoveTop.visibility = View.INVISIBLE
                    llSetting.visibility = View.INVISIBLE
                }
            }
        }
    }

    fun enableSetting(enabled: Boolean) {
        binding?.imgSetting?.isSelected = enabled
        binding?.llSetting?.isEnabled = enabled
    }

    fun setOnSearchClick(action: () -> Unit) {
        binding?.llSearch?.setOnClickListener { action.invoke() }
    }

    fun setOnInviteClick(action: () -> Unit) {
        binding?.llInvite?.setOnClickListener { action.invoke() }
    }

    fun setOnMoveTopClick(action: () -> Unit) {
        binding?.llMoveTop?.setOnClickListener { action.invoke() }
    }

    fun setOnSettingClick(action: () -> Unit) {
        binding?.llSetting?.setOnClickListener { action.invoke() }
    }

}